package com.servlet;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.domain.AllCart;
import com.domain.User;
import com.service.orderService;
import com.util.UUID_32;

/**
 * 
 * 功能描述：购物车提交订单Servlet
 * 
 * Version： 1.0
 * 
 * date： 2016年6月25日 下午11:49:51
 * 
 * @author：XiaoBingBy
 *
 */
public class CartOrderServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    public CartOrderServlet() {
        super();
    }

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		int flage = Integer.valueOf(request.getParameter("flage"));
		HttpSession session = request.getSession();
		User myUser = (User) session.getAttribute("MyUser");
		if (flage==1) {
			List<AllCart> allCatInfo = (List<AllCart>) session.getAttribute("allCart");
			orderService orderService = new orderService();
			orderService.addOrder(UUID_32.getUUID(), myUser.getUsername(),  allCatInfo);
			
			//添加订单待处理跳转页面
		} else if (flage==2) {
			orderService orderService = new orderService();
			orderService.addOnOrder(UUID_32.getUUID(), myUser.getUsername(), request.getParameter("goods_id"));//添加一个订单
			
			//添加订单待处理跳转页面
		}
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doGet(request, response);
	}

}
